class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :hometown
  # attr_accessible :title, :body
  has_friends

  def requested_friends
    Friendship.where(:user_id => self.to_param,
                     :status => 'requested').collect { |f| User.find(f.friend_id) }
  end
end
